var jsHelper = {
	getRootPath: function() {
		var pathName = window.location.pathname.substring(1);
		var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
		var rootPath = window.location.protocol + '//' + window.location.host + '/'+ webName + '/';

		return rootPath;
	},
	getRootPath2: function(){
		var strFullPath=window.document.location.href;
		var strPath=window.document.location.pathname;
		var pos=strFullPath.indexOf(strPath);
		var prePath=strFullPath.substring(0,pos);
		var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
		return(prePath+postPath);
	},
	getElementsByClassName: function (strClassName, oElm, strTagName) {
		if (oElm == undefined) {
			oElm = 'document';
		}
		if (strTagName == undefined) {
			strTagName = '*';
		}
		var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
		var arrReturnElements = new Array();
		strClassName = strClassName.replace(/-/g, "\-");
		var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
		var oElement;
		for(var i=0; i<arrElements.length; i++) {
			oElement = arrElements[i];
			if(oRegExp.test(oElement.className)) {
				arrReturnElements.push(oElement);
			}
		}
		return (arrReturnElements)
	},
	getElements: function(elem) {
		elem = jsHelper.trimString(elem);
		var name = elem.substr(1);
		if(elem.indexOf('#') > -1) {
			return document.getElementById(name);
		} else if (elem.indexOf('.') > -1) {
			return jsHelper.getElementsByClassName(name);
		} else {
			return false;
		}
	},
	divSameHeight: function(div1, div2) {
		div1 = jsHelper.getElements(div1);
		div2 = jsHelper.getElements(div2);
		if(div1 === false || div2 === false) {
			return;
		}
		/*if (!div1.length || !div2.length) {
			return;
		}*/
		var height1 =jsHelper.getStyle(div1, 'height');
		var height2 =jsHelper.getStyle(div2, 'height');
		var value1 = height1.replace(/[^\d]/g,'');
		var value2 = height2.replace(/[^\d]/g,'');
		if (parseInt(value1) > parseInt(value2)) {
			jsHelper.setStyle(div2, 'height', height1);
		} else {
			jsHelper.setStyle(div1, 'height', height2);
		}
	},
	setStyle: function (elem,name,prop) {
		var old = elem.style[name];
		elem.style[name] = prop;
		return old;
	},
	getStyle: function (elem,name) {
		if(elem.style[name]) {
			return elem.style[name];
		} else if(elem.currentStyle) {
			return elem.currentStyle[name];
		} else if(document.defaultView&&document.defaultView.getComputedStyle) {
			name=name.replace(/([A-Z])/g,"-$1");
			name=name.toLowerCase();
			var s=document.defaultView.getComputedStyle(elem,"");
			return s&&s.getPropertyValue(name);
		} else {
			return null
		}
	},
	formatDate: function(date,format) {
		var o = {
			"M+" : date.getMonth()+1, //month
			"d+" : date.getDate(),    //day
			"h+" : date.getHours(),   //hour
			"m+" : date.getMinutes(), //minute
			"s+" : date.getSeconds(), //second
			"q+" : Math.floor((date.getMonth()+3)/3), //quarter
			"S" : date.getMilliseconds() //millisecond
		}
		if(/(y+)/.test(format))
			format=format.replace(RegExp.$1,
			(date.getFullYear()+"").substr(4 - RegExp.$1.length));
		for(var k in o)
			if(new RegExp("("+ k +")").test(format))
				format = format.replace(RegExp.$1,
				RegExp.$1.length==1 ? o[k] :
				("00"+ o[k]).substr((""+ o[k]).length));
		return format;
	},
	trimString: function(string) {
		return string.replace(/(^\s*)|(\s*$)/g,"");
	},
	replaceString: function (AFindText,ARepText,string) {
		raRegExp = new RegExp(AFindText,"g");
		return string.replace(raRegExp,ARepText);
	}
}